home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
manual-p
/
vh-man2h.000
/
vh-man2h
/
vh-man2html-1.3
/
README
< prev
next >
Wrap
Text File
|
1996-05-04
|
12KB
|
287 lines
Caldera/Redhat oriented front ends to man2html
----------------------------------------------
Michael Hamilton <michael@actrix.gen.nz>
http://www.actrix.gen.nz/users/michael
Translate man pages to html from tbl/nroff source.
New in version 1.3:
- Tested/fixed bug with serving pages to remote UNIX hosts.
- Added man pages for man2html(8) and netscape-man(1).
- Renamed from man2html-linux to vh-man2html to avoid confusion with the
numerous man2html's out there (most of the others work from nroff output).
Also it is not really Linux specific - with minimal tailoring it could
work on any UNIX box that uses source based man pages.
vh = Richard Verhoeven's Man2html as modified and packaged up by Michael
Hamilton.
New in version 1.2:
- I've enhanced man2hmtl.c so that it can format BSD mandoc man pages.
This means it can now cope with all the Caldera/Redhat man pages
(eg telnet, ftp, and lpr are now converted correctly).
- Added /usr/bin/netscape-man script which performs like the man command
but talks to a live (already running) netscape to present pages, e.g.
netscape-man lpr - netscape pops up lpr man page.
netscape-man 8 sendmail - pops up sendmail (8) man page.
netscape-man 7 into - pops up name+description index for sec 7.
netscape-man 5 - pops up name-only index for sec 5.
netscape-man -k pine - pops up a glimpse text search for pine.
You can alias man to netscape-man in your shell .profile or .cshrc.
- I revisited the awk scripts, mansec index creation time has been
reduced considerably on larger sections. From 25 seconds down to
10 on my 486DX2/66 for Section 3 with about 950 man pages.
- Manwhatis index creation time has also been reduced. From 1 minute
down to 8 seconds for the same section.
- Temporary files are now suffixed with the process id in case two or
more people simultaneously invoke them.
- The scripts now do safer (mv based) updates of the cache files to prevent
errors due to more than one person simultaneously updating them.
- Support for makewhatis programs that produce full section numbers
e.g. they produce xterm(1x) rather than xterm(1). See the end of
this file for a patch to makewhatis from man-1.4g.
- Fixed core dumping on Gawk.1 page.
- Fixed malloc bug(s) (eg don't try the lynx.1 page with version 1.1 -
corrupt memory = infinite loop). Did this by def'ing free to do
nothing - ie leak until exit() - it doesn't run long, and doesn't
malloc much anyway - trust me.
New in version 1.1:
- Full text search via glimpse.
- All scripts now generate valid, stylistically correct, html according to
weblint (see http://www.khoros.unm.edu/staff/neilb/weblint.html).
- Consistent titles and headers.
- More compact Main Contents page.
QUICK START INSTRUCTIONS
------------------------
To use these cgi scripts all you have to do is install the rpm and
then point your web browser at
http://localhost/cgi-bin/man2html
You can either save this location as a bookmark or use an editor to
insert the following lines into an appropriate place in
/usr/doc/HTML/calderadoc/caldera.html
<H3><A HREF="http://localhost/cgi-bin/man2html"><IMG SRC="book2.gif">
Caldera Linux Manual Pages</A></H3>
For some of the indexes to work you must generate the necessary
databases...
My manwhatis CGI script uses the /usr/man/whatis file to build
a man page index. Caldera 1.0 normally builds the /usr/man/whatis every
morning at 3:21am. If this job has never been run (perhaps because
you turn your machine off at night), you can build it by becoming the
root user and entering:
/usr/sbin/makewhatis /usr/man /usr/X11R6/man /usr/local/man
WARNING: makewhatis in Caldera 1.0 takes about 30 minutes on my
486DX66. I have a modified version of makewhatis so that it does
exactly the same job in only 1.5 minutes. My modified version is now
available as part of man-1.4g.tar.gz:
ftp://sunsite.unc.edu/pub/Linux/system/Manual-pagers
To use the Glimpse full text searching, you will need to install
glimpse in /usr/bin. Redhat rpm users can get glimpse from
ftp://ftp.redhat.com/pub/non-free/glimpse-3.0-1.i386.rpm
The glimpse home ftp site is cs.arizona.edu. N.B. glimpse is not
freely redistributable for commercial use, I'd be very interested in a
more liberal alternative. Having installed glimpse, you will need to
build a glimpse index in /var/man2html. This doesn't take too long -
about 3 minutes on my 486DX2/66 16MB machine. As root do:
/usr/bin/glimpseindex -H /var/man2html /usr/man/man* /usr/X11R6/man/man* \
/usr/local/man/man* /opt/man/man*
chmod +r /var/man2html/.glimpse*
This could be set up as a cron job in /etc/crontab, e.g. (the following
must be all on one line):
21 04 * * 1 root /usr/bin/glimpseindex -H /var/man2html /usr/man/man*
/usr/X11R6/man/man* /usr/local/man/man* /opt/man/man* ;
chmod +r /var/man2html/.glimpse*
If you don't want to use glimpse you can edit the man.html file that
the package installs in /home/http/html/man.html, and remove the
references to full text searches and glimpse. This file can also be
edited to include any local instructions you might wish to include.
The scripts may generate errors to the httpd error log
/var/log/httpd/error_log. The man binary (used to obtain the man-path
by some of the scripts) seems to always think it's talking to a tty,
and tries to obtain the screen size, resulting in the following error
log entries:
TIOCGWINSZ
failed : Bad file number
To serve man pages to remote hosts, all that is required is a httpd
daemon that sets the environment variable SERVER_NAME correctly.
END OF QUICK START INSTRUCTIONS
-------------------------------
Vh-man2html was was written by Richard Verhoeven (NL:5482ZX35) at
the Eindhoven University of Technology (Email: rcb5@win.tue.nl). The
original source is available from his web page at:
http://wsinwp01.win.tue.nl:1234/maninfo.html
There are other man2html programs around - Richard's page has links to
several of them. Richard's man2html has some useful features for
Caldera/RedHat Linux -
Works from the troff/nroff source pages.
With linux we almost always have the man source.
Doesn't have to run man+tbl+eqn+nroff to generate output.
Because man isn't run, no catman pages are generated.
Accurate - doesn't have to guess from the man output.
Does tables (eg man ascii) (but doesn't do eqn - few pages use eqn).
Written in C - efficient speed/memory usage.
Fast enough not to need a cache.
Intelligent
Makes good guesses on where to find pages.
Creates links for man pages and include files.
Richard's original program copes with pages formatted with the man
macros. I've enhanced it by adding translations for the mandoc macros
used in the BSD man pages. BSD mandoc pages in Caldera/Redhat
include Mail, ftp, telnet, rlogin, and lpr and other printer man
pages - so they're pretty important.
I don't have any documentation on the mandoc macros, so I've had to
guess what they intend, by looking at man source, man output and the
gnroff macro definitions. I've tested it on all the BSD mandoc pages
in Section 1 that I could find. It works reasonable well. There are
still minor formatting glitches to do with punctuation placement.
I checked the BSD mandoc with weblint, e.g. in tcsh/csh
foreach i ( `egrep -l '^\.Bl' /usr/man/man1/* /usr/man/man8/*` )
/home/httpd/cgi-bin/man2html $i > tmp/`basename $i`
end
weblint tmp/*
For broader testing:
find /usr/man/man* -name '*.[0-9]' \
-printf "echo %p; /home/httpd/cgi-bin/man2html %p | weblint -x netscape -\n" \
| sh \
|& tee weblint.log
If you want to sample the spectrum of mandoc translation, look at
any of the pages the above grep locates, telnet, lpc, and mail
are good examples.
As well as the mandoc modifications, I've also modified and configured
man2html for Caldera/RedHat, and I've made the code a little more
robust (for full details see the patch included in the source
archive). I've added index cgi scripts and a "main" html page. The C
source has been modified to link generated html man pages back to the
"main" page.
Here's a summary of the rpm's components:
1) man.html - Main page or access to man2html and man indexes.
2) man2html - CGI binary that converts man pages to html.
3) manwhatis - CGI script for a name and synopsis index organised
by manual section
4) mansec - CGI script for a name only index for each section.
5) mansearch - Glimpse full text searching.
6) mansearch.html - Main page or access to man2html and man indexes.
7) /var/ma2html - Cache directory for indexes and glimpse indexes.
All my scripts are written in awk. In detail...
The manwhatis script creates section contents html files by looking
for whatis files along the man path. Each whatis entry is translated
to a man2html link. Manwhatis caches it's output in
/var/man2html/whatis-[0-9].html. The cache will be regenerated if any
whatis file in the man path is updated (eg touch /usr/man/whatis).
The mansec script lists the names of all manual pages for a given
section by using find on the man path. It caches its output in
/var/man2html/manindex-[0-9].html. The cache will be regenerated if
any associated man[0-9] directory in the man path is updated.
The mansearch script uses glimpse to get back a list of files and
matches which it links back to the actual man pages. The mansearch
script is not pure awk. It's starts out as a shell script to ensure
that the parameters are safely passed to awk. I think it's secure,
but I'm not a cgi script expert.
To build and install man2html, the scripts, and man.html from the
source archive.
make install
To build binary and source rpms, placing them under /usr/src/...
make rpm
---------------
Patch to makewhatis from man-1.4g so that makewhatis will produce
full section details: e.g. xterm(1x) rather than xterm(1). Put the
patch in a file and enter:
cd /usr/sbin
patch < thepatchfile
--- cut here ---
--- man-1.4g/src/makewhatis.sh Tue Apr 2 10:51:14 1996
+++ makewhatis Mon Apr 8 17:54:47 1996
@@ -157,6 +157,12 @@
filename ~ /\.gz$/);
match(filename, "/[^/]+$");
progname = substr(filename, RSTART + 1, RLENGTH);
+ if (match(progname, "\." section "[A-Za-z]*")) {
+ actual_section = substr(progname, RSTART + 1, RLENGTH);
+ }
+ else {
+ actual_section = section;
+ }
sub(/\..*/, "", progname);
if (use_zcat) {
pipe_cmd = "zcat " filename;
@@ -246,7 +252,7 @@
where = 0;
}
printf "%-*s", 20-charct, sprintf( "%s (%s)",
- substr( $0, 0, where-1 ), section );
+ substr( $0, 0, where-1 ), actual_section );
printf "%s", substr( $0, where )
if ($0 ~ /- *$/) {
needmore = 1;
--- cut here ---
---------------
My modifications, packaging and scripts are copyright (c) 1996
Michael Hamilton (michael@actrix.gen.nz). All rights reserved.
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that the
above copyright notice and the following two paragraphs appear in all
copies of this software.
IN NO EVENT SHALL MICHAEL HAMILTON BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF MICHAEL
HAMILTON HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MICHAEL HAMILTON SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND MICHAEL HAMILTON HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Michael